<?php
namespace App\Controllers;
use App\Models\MemberBenefitModel;
use App\Models\MemberModel;
use App\Services\MemberService as Service;
use Framework\BaseController;

class MemberController extends BaseController
{
    /**
     * @var Service
     */
    private $service;

    public function __construct(Service $service)
    {
        $this->service = $service;
    }

    public function getMemberInfo()
    {
        $info = MemberModel::query()->get()->makeHidden(['created_at','updated_at']);
        if(!empty($info)){
            $info->map(function ($item){
               $tags = json_decode($item->benefits_tags);
               $item->quanyi = MemberBenefitModel::query()->whereIn('id',$tags)->get();
               return $item;
            });
        }
        return $info;
    }

}
